<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>大咖vip_未登录</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <link rel="stylesheet" type="text/css" href="../../css/freevideo.css" />
    <style>
        .last {
            text-align: center;
            background: #fff;
            width: 300px;
            height: 200px;
            left: 50%;
            /*top: 50%;*/
            position: absolute;
            margin-left: -150px;
            margin-top: 20px;
            color: #dedede;
        }
        .lists{
          position: relative;
        }
        .cat {
            width: 118px;
            height: 90px;
            margin: 0 auto;
        }

        .content {
            margin-top: 24px!important;
        }

        .tupian {
            position: relative;
        }


        .fixedhead {
            position: fixed;
            height: 45px;
            top: 0px;
            left: 0px;
            right: 0px;
            background-color: #fff;
            z-index: 10;
        }
        /*分享*/

        .sharesuccess {
            background-color: #3F3A39;
            width: 99px;
            color: #fff;
            text-align: center;
            border-radius: 10px;
            padding: 10px;
            position: absolute;
            top: 50%;
            margin-top: -43px;
            left: 50%;
            margin-left: -48px;
            display: none;
        }

        .shareimg {
            width: 37px;
            height: 34px;
            margin: 0 auto 10px;
        }

        .sharetext {
            font-size: 14px;
        }

        .getscore {
            font-size: 12px;
        }
        /*分享end*/

        .img_avatervip {
            position: absolute;
            /* border: 13px; */
            left: 24px;
            top: 30px;
            border-radius: 10px;
        }

        .share {
            position: relative;
        }
        .collectsuccess {
            /*background: #fff;*/
            /*background: rgba(190,190,190, 0.3);*/
            border-radius: 20px;
            width: 225px;
            height: 261px;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            padding-top: 15px;
            display: none;
        }
        .test{
          position: relative;
          overflow: hidden;
        }
        .content00{
          width: 100%;
          font-size: 15px;
          font-weight: bold;
          color: #333;
        }
        .content11{
          width: 100%;
          font-weight: bold;
          font-size: 14px;
          padding: 0px;
          height: auto;
        }
        .content22{
          font-size: 14px;
          color: #56dbfd;
          width: 100%;
          font-weight: bold;
          padding: 0px;
        }
        .downerror{
          height: 80px;
              margin-top: 80px;
              text-align: center;
        }
        .chongshi{
          font-size: 14px;
          padding: 5px 15px;
          border-radius: 15px;
          color: #fff;
          background-color: #666;
          margin-top: 15px;
          display: inline-block;
        }
        .cat1{
          width: 250px;
          height: auto;
        }
        .duihuansuccess,.buysuccess {
            width:120px;
            color: #fff;
            text-align: center;
            border-radius: 10px;
            padding: 10px;
            position: absolute;
            top: 50%;
            margin-top: -60px;
            left: 50%;
            margin-left: -60px;
            display: none;
            z-index:999999;
        }

    </style>
</head>

<body>
    <div id="vm" v-cloak>
        <div class="fixedhead"></div>
        <header id="aui-header">
        </header>
        <div class="video test">
          <div class="downerror"  v-show='wangluo'>
              <p>视频加载失败</p>
              <span class="chongshi" @click=chongshi()>点击重试</span>
          </div>
        </div>
        <div class="title">
            <!-- <div class="button" onclick="openVIP()" v-show="videodetial.video_type==2 && !isviphuiyuan">开通VIP会员，观看更多优质影片</div> -->
            <div class="button" style="background-color:#C10F22" @click="goumaidaka(videodetial.video_free_cash,videodetial.video_vip_cash,videodetial.id,videodetial.endtime,videodetial.is_forever)" v-if="videodetial.video_type==3 && videodetial.is_valite==0">大咖观看</div>
            <div class="title_first">
                <div class="title_lf" v-html="videodetial.video_name"></div>
                <span v-if="dianjiflag" @click="transform()">
                   <div style="float:right;color:#C7C8C8;font-size:13px; title_f_lf">
                       详情&nbsp;&nbsp;<img src="../../image/my/jiantou.png" alt="" class="img_jt">
                   </div>
                   <div class="aui-clearfix"></div>
                </span>
                <span v-else @click="transforms()">
                    <img src="../../image/VIP/gary.png" alt="" class="img_jt1">
                    <div class="aui-clearfix"></div>
              </span>
                <div class="aui-clearfix"></div>
            </div>
            <div class="dianzan">
                <div style="font-size:13px;float:left;color:#A5A5A5">{{playmethod(videodetial.watch_count)}}次播放</div>
                <div style="float:right;color:#A5A5A5;font-size:14px;font-family:Adobe Heiti Std R;font-weight:normal;">
                    <span v-if="videodetial.isZan==1 && weidianji" @click="cancelzan()">
                       {{zanmethod(videodetial.zan_count)}}&nbsp;&nbsp;<img src="../../image/VIP/praises.png" alt="" class="img_prs">
                    </span>
                    <span v-if="videodetial.isZan==0 && weidianji1" @click="zan()">
                       {{zanmethod(videodetial.zan_count)}}&nbsp;&nbsp;<img src="../../image/VIP/praise.png" alt="" class="img_prs">
                    </span>
                    <span v-if="videodetial.isZan==1 && !weidianji" @click="cancelzan()">
                       {{zanmethod(videodetial.zan_count)}}&nbsp;&nbsp;<img src="../../image/VIP/praises.png" alt="" class="img_prs">
                    </span>
                    <span v-if="videodetial.isZan==0 && !weidianji1" @click="zan()">
                       {{zanmethod(videodetial.zan_count)}}&nbsp;&nbsp;<img src="../../image/VIP/praise.png" alt="" class="img_prs">
                    </span>
                </div>
                <div class="aui-clearfix"></div>
            </div>
            <div class="aui-clearfix"></div>
        </div>
        <div class="dianji hide">
            <div class="details">
                <div style="font-size:16px;color:#5F5F5F;padding:6px 0px;font-weight:500">{{videodetial.author}}</div>
                <p class="name_details" v-html="videodetial.author_introduce"></p>
            </div>
            <div class="details">
                <div style="font-size:16px;color:#5F5F5F;padding:6px 0px;font-weight:500">介绍</div>
                <p class="name_details" v-html="jiequ(videodetial.video_introduce)"></p>
            </div>
        </div>
        <div class="share">
            <img v-bind:src="avatar" alt="" class="img_avater" style="border-radius:50%;float:left;margin-right:8px;">
            <!-- <img v-show="level==1" src="../../image/VIP/vip.png" alt="" class="img_avatervip"> -->
            <div style="color:#A5A5A5;font-size:15px;padding-left:3px;width:40%;float:left;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;line-height:28px;">{{nickname}}</div>

            <img src="../../image/VIP/share.png" alt="" class="image" @click="share(videodetial.isrecommand)">

            <span v-if="videodetial.isFavorite==1" @click="discollect()">
                <img src="../../image/VIP/heart.png" alt="" class="image1" >
            </span>
            <span v-else @click="collect()">
                <img src="../../image/VIP/heart2.png" alt="" class="image1" >
            </span>

              <img src="../../image/VIP/learn.png" alt="" class="image2" v-show="videodetial.video_type!=1  && videodetial.is_score==1 && videodetial.is_valite==0 " @click="duihuan(videodetial.score,videodetial.endtime,videodetial.is_forever)">
              <img src="../../image/my/study.png" alt="" class="image2" v-show="yiduihuan" @click="yiduihuanmethod()">
            <!-- </span> -->
            <img src="../../image/VIP/shopping.png" alt="" class="image2" v-show="videodetial.video_type==2 && videodetial.is_valite==0 && level==0" @click="goumai(videodetial.video_free_cash,videodetial.id,videodetial.endtime,videodetial.is_forever)">
            <!-- <img src="../../image/VIP/shopping.png" alt="" class="image2" v-show="videodetial.video_type==3 && videodetial.is_valite==0" @click="goumai(videodetial.video_free_cash,videodetial.id,videodetial.endtime,videodetial.is_forever)"> -->
            <!-- <img src="../../image/VIP/learn.png" alt="" class="image2" v-show="videodetial.video_type!=1  && videodetial.is_score==1 && videodetial.is_valite==0 && !isviphuiyuan" @click="duihuan(videodetial.score,videodetial.endtime,videodetial.is_forever)">
            <img src="../../image/VIP/shopping.png" alt="" class="image2" v-show="videodetial.video_type==2 && videodetial.is_valite==0 && !isviphuiyuan" @click="goumai(videodetial.video_free_cash,videodetial.id,videodetial.endtime,videodetial.is_forever)"> -->
            <div class="aui-clearfix"></div>
        </div>


        <div class="lists" v-show="!wangluo">
            <div v-if="isauthorvideolistflag">

                <div style="font-size:13px;color:#a5a5a5">作者视频</div>
                <div style="margin-top:5px;" @click="Openjieshao(item)" v-for="item in authorvideolist">
                    <div class="tupian">
                        <!-- <span class="videotype" :class="{videotypedaka:item.video_type==3,videotypemianfei:item.video_type==1}">{{videotype(item.video_type)}}</span> -->
                        <img v-bind:src="item.img" alt="" class="img_picture">
                    </div>
                    <div class="content1 test">
                        <p class="content_title aui-ellipsis-2" v-html="item.video_name"></p>
                        <p class="content_wenzi aui-ellipsis-1"  v-html="item.video_introduce_small"></p>
                        <div class="shuoming">观看人次：{{item.watch_count}}</div>
                        <!-- <div class="shuoming right">{{watchtime(item.addtime)}}</div> -->

                    </div>
                    <div class="aui-clearfix"></div>
                </div>
                <div class="watchall" id="alldivs" v-show="authorvideolist" @click="OpenWatchAllVieo(videodetial.author,videodetial.author_id,videoid)">查看全部</div>
            </div>
            <div v-else>
                <div style="font-size:13px;color:#a5a5a5">相关视频</div>

                <div class="last">
                    <img src="../../image/home/cat_1.png" alt="" class="cat">
                    <div class="content">暂无相关视频</div>
                </div>
            </div>
          </div>

        <div class="lists"  v-show='wangluo'>
              <div class="last">
                  <img src="../../image/few/aliens.png" alt="" class="cat cat1">
                  <div class="content00">网络不给力</div>
                  <div class="content11">世界上最遥远的距离，莫过于网络不给力</div>
                  <div class="content22"  @click=chongshi()>刷新</div>
              </div>

      </div>
        <!-- <div class="sharesuccess">
            <img src="../../image/1.png" class="shareimg" alt="">
            <div class="sharetext">分享成功</div>
            <div class="getscore">获得学分<span style="color:#EA5413"> + {{sharevideo}}</span></div>
        </div> -->

          <div class="collectsuccess">
              <img src="../../image/VIP/20.png" alt="" style="position:absolute;right:63px;top:69px;width:92px;">
          </div>
          <div class="duihuansuccess">
              <img src="../../image/VIP/25.png" alt="">
          </div>
          <div class="buysuccess">
              <img src="../../image/VIP/24.png" alt="">
          </div>

    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/rest.js"></script>
<script type="text/javascript" src="../../script/vue.2.5.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/video.js"></script>
<script type="text/javascript" src="../../script/playmodule.js"></script>
<script type="text/javascript" src="../../script/showdate.js"></script>
<script type="text/javascript" src="../../script/faskclick.js"></script>
<script type="text/javascript">
    var uid,session;
    var isyongjiu;
    var vm = new Vue({
        el: '#vm',
        data: {
            dianjiflag: true,//控制作者详情的
            flage_p: false,
            ifliuliang: false,//是否是4g
            videodetial: {//音乐详情
                zan_count: '',
                video_play_number_2: '',
                video_name: '',
                video: ''
            },
            wangluo:false,//判断网络是否断了
            bfstyle: 'bofang',//播放状态控制标签的
            quanping: false,//是否是全屏
            playstate: false,//播放中监听的状态
            settime: '',//
            settime2:'',
            avatar: '../../image/VIP/gray_touxiang.png',
            nickname: '',
            isviphuiyuan: false,
            duihuanflag:false,
            // 收藏和作者其他视频
            authorvideolist: [],
            kongzhiflage: true,
            liuliangflag: true,
            level: 0,
            isauthorvideolistflag: false,
            histortlist: [],
            video_content: {},
            sharevideo: '',
            videobg: '',
            vidoeadstate:false,
            isLock:false,
            watchtimes:0,
            alltime:1,
            firstjiazai:true,//第一次加载
            daodabofangshijian:false,
            yiduihuan:false,
            watch:false,
            weidianji:true,
            weidianji1:true,
            eventType:1,
            xiuxi:false
        },
        created: function() {
            var _this = this;
            apiready = function() {
                api.parseTapmode();
                 uid = $api.getStorage('uid');
                 session = $api.getStorage('session');
                var header = $api.byId('aui-header');
                $api.fixStatusBar(header);
                var headerPos = $api.offset(header);
                if ('addEventListener' in document) {
                    document.addEventListener('DOMContentLoaded', function() {
                        FastClick.attach(document.body);
                    }, false);
                }
                setTimeout(function() {
                  $api.fixTabBar($api.byId('alldivs'))
                },1000)
                _this.getXueRule()
                    // 在我的页面监听，调用观看历史接口
                if (uid) {
                    api.sendEvent({
                        name: 'watchvideo',
                    });
                }
                _this.watch = api.pageParam.watch


                //监听返回键
                //监听video的播放状态
                api.addEventListener({
                    name: 'advieostase'
                }, function(ret, err) {
                    _this.vidoeadstate=ret.value.eventType
                });

                api.addEventListener({
                    name: 'loginsuccess'
                }, function(ret, err) {
                  // uid = $api.getStorage('uid');
                  // session = $api.getStorage('session')
                  // var item ={id:api.pageParam.videoid}
                  // vm.Openjieshao(item);
                  setTimeout(function() {
                    api.closeWin();
                  },500)
                });

                api.addEventListener({
                    name: 'daodabofangshijian'
                }, function(ret, err){
                    if( ret ){
                      _this.daodabofangshijian = true
                    }
                });
                api.addEventListener({
                    name: 'daodabofangshijian1'
                }, function(ret, err){
                    if( ret ){
                      _this.daodabofangshijian = false
                    }
                });


                api.addEventListener({
                    name: 'setbeisu'
                }, function(ret, err) {
                    _this.beisuplay(ret.value.videobeisu)
                });
                api.addEventListener({
                    name: 'qiehuanfullscreen'
                }, function(ret, err) {
                    _this.unfull()
                });
                api.addEventListener({
                    name: 'qiehuanfullscreen1'
                }, function(ret, err) {
                    if (_this.quanping) {
                        _this.unfull()
                    } else {
                        var ijkplayer = api.require('ijkplayer');
                        ijkplayer.close();
                        api.closeWin();
                    }
                });
                api.addEventListener({
                    name: 'quallfull'
                }, function(ret, err) {
                  _this.isFullScreen(function() {
                      if (_this.quanping) {
                          _this.unfull()
                      } else {
                          _this.full()
                      }
                  })
                });
                api.addEventListener({
                  name: 'settimedaojishi'
              }, function(ret, err) {
                  if (ret.value.falg==0) {
                      _this.bofangvideo(true)
                  }
                })


                api.addEventListener({
                    name: 'liuliangname'
                }, function(ret, err) {
                    _this.liuliangflag = false
                });
                api.addEventListener({
                    name: 'duihuansuccess'
                }, function(ret, err) {


                    $('.duihuansuccess').css('display', 'block');
                    setTimeout(function() {
                        $('.duihuansuccess').css('display', 'none');
                    }, 1500);
                    _this.yiduihuan=true;
                    Vue.set(_this.videodetial, 'is_valite', 1);
                });


                //监听返回键
                api.addEventListener({
                    name: 'detialkeyback'
                }, function(ret, err) {
                    // _this.isFullScreen(function() {
                        if (_this.quanping) {
                            _this.unfull()
                        } else {
                            var ijkplayer = api.require('ijkplayer');
                            ijkplayer.close();
                            api.closeWin();
                        }
                    // })
                });
                api.addEventListener({
                    name: 'bofang'
                }, function(ret, err) {
                  if (_this.daodabofangshijian) {

                  }else {
                    vm.bofang()
                  }

                });
                //监听
                api.addEventListener({
                    name: 'playvidoead'
                }, function(ret, err) {
                    vm.playvidoead(_this.videodetial)
                });


                _this.wangluo2()


                //监听放大缩小
                api.addEventListener({
                    name: 'allfull'
                }, function(ret, err) {
                    _this.isFullScreen(function() {
                        if (_this.quanping) {
                            _this.unfull()
                        } else {
                            _this.full()
                        }
                    })
                });
                api.addEventListener({
                    name: 'allauthorvideo'
                }, function(ret, err) {
                    _this.videoid = ret.value.videoid;
                    // _this.getuserinfo();
                    var item ={id:ret.value.videoid}
                    _this.Openjieshao(item)
                });
                //设置settime
                api.addEventListener({
                    name: 'settime'
                }, function(ret, err) {
                    if (ret) {
                        vm.seekTo(ret.value.value)
                    }
                });
                api.addEventListener({
                    name: 'replay'
                }, function(ret, err) {
                    vm.replay()
                });

                api.addEventListener({
                    name: 'zanting'
                }, function(ret, err) {
                    vm.zanting()
                });

                api.addEventListener({
                    name: 'paysuccess'
                }, function(ret, err) {
                    var item ={id:api.pageParam.videoid}
                    vm.Openjieshao(item);
                    $('.buysuccess').css('display', 'block');
                    setTimeout(function() {
                        $('.buysuccess').css('display', 'none');
                    }, 1500);
                });

                api.addEventListener({
                    name: 'states'
                }, function(ret, err) {
                    vm.dianjistast()
                    if (_this.ifliuliang) {
                        api.openFrame({
                            name: '4gplay',
                            url: './../video/4gplay.html',
                            rect: {
                                x: api.frameWidth / 2 - 80,
                                y: 80 + api.safeArea.top,
                                w: 160,
                                h: 40
                            },
                            pageParam: {
                                size: _this.videodetial.size
                            }
                        });
                    } else {
                      // if (api.systemType=='ios') {
                      //     vm.replay()
                      // }else {
                      //   vm.bofang()
                      // }
                      vm.bofangvideo(true)
                    }
                });
                if (api.connectionType=="none") {
                    _this.wangluo=true;
                    api.toast({
                        msg: '暂无网络',
                        duration: 2000,
                        location: 'bottom'
                    });
                    return;
                }
                _this.init();
            }
        },
        methods: {
            init: function() {
                var _this = this;
                _this.videoid = api.pageParam.videoid;
                _this.getuserinfo();
                _this.dianjistast();
            },
            yiduihuanmethod:function () {
              api.toast({
                  msg: '已兑换成功，请勿重复兑换',
                  duration: 2000,
                  location: 'middle'
              });

            },
            wangluo2:function() {
              //网络类型
              var _this = this;
              var connectionType = api.connectionType;
              if(connectionType == '4g' || connectionType == '4G'){
                  _this.ifliuliang = true
                  _this.liuliangflag = true
              }else{
                _this.ifliuliang = false
                _this.liuliangflag = false
              }
            },
            videotype: function(res) {
                if (res == 2) {
                    return 'VIP'
                } else if (res == 3) {
                    return '大咖'
                } else {
                    return '免费'
                }
            },
            jiequ(shipinjieshao){
              if(shipinjieshao){
                return shipinjieshao.substring(0, 500)
              }
            },
            watchtime(riqi) {
                return Mou.watchtime(riqi);
            },
            getXueRule() {
                var _this = this;
                new rest().get('getRule').success(function(res) {
                    if (res.flag == 1) {
                        _this.sharevideo = res.msg.share_video;
                    } else {
                        api.toast({
                            msg: res.msg,
                            duration: 2000,
                            location: 'middle'
                        });
                    }
                }).error(function(err) {
                    console.log(JSON.stringify(err))
                }).run()
            },
            dianjistast: function() {
                var _this = this;
                //状态事件
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.addEventListener({
                    name: 'state'
                }, function(ret, err) {
                    if (ret) {
                        // console.log(JSON.stringify(ret)+'state')
                        if (ret.eventType == 'statePlaying') {
                          _this.eventType=ret.eventType;
                            _this.bofangtime()
                            _this.upwatch()
                            setTimeout(function() {
                              api.sendEvent({
                                  name: 'statePlaying',
                                  extra: {
                                      state: 'palying'
                                  }
                              });
                            },500)
                            if (_this.videodetial.last_watch&&_this.firstjiazai&&_this.watch) {
                              // alert(_this.firstjiazai)
                              var gotime = parseInt(_this.videodetial.last_watch/1000);
                                ijkplayer.seekTo({
                                    seconds: gotime
                                });
                                _this.firstjiazai= false
                            }

                        } else if (ret.eventType == 'statePaused'  || ret.eventType == 'stateStop' || ret.eventType == 'stateError') {
                            clearInterval(_this.settime)
                            clearInterval(_this.settime2)
                            api.sendEvent({
                                name: 'statePlaying',
                                extra: {
                                    state: 'stop'
                                }
                            });
                        } else if (ret.eventType == 'stateCancelFull') {
                            quxiaoqunpingstate()
                            _this.quanping = false

                        } else if (ret.eventType == 'stateFullScreen') {
                            _this.quanping = true
                            quanpingstate()
                        }else if (ret.eventType == 'clickLock') {
                          _this.isLock =true
                          api.setFrameAttr({
                              name: 'beisu',
                              hidden: true
                          });
                          api.setFrameAttr({
                              name: 'videocontrl',
                              hidden: true
                          });
                          api.toast({
                                   msg: '屏幕已锁定',
                                   duration: 500,
                                   location: 'bottom'
                               });
                        }else if (ret.eventType == 'clickUNLock') {
                          _this.isLock =false
                          api.toast({
                                   msg: '屏幕已解锁',
                                   duration: 500,
                                   location: 'bottom'
                               });
                        }

                        if (ret.eventType == 'statePaused' || ret.eventType == 'stateStop') {
                          clearInterval(_this.settime)
                          clearInterval(_this.settime2)
                          _this.playstate = true
                        }else if (ret.eventType == 'stateComplete') {
                          clearInterval(_this.settime)
                          clearInterval(_this.settime2)
                          _this.eventType=ret.eventType;
                            api.sendEvent({
                                name: 'positiotime',
                                extra: {
                                    value: _this.alltime,
                                }
                            });
                            api.sendEvent({
                                name: 'Complete'
                            });
                        }
                    }
                });
                //点击事件
//                 ijkplayer.addEventListener({
//                     name: 'click'
//                 }, function(ret, err) {
//                     if (ret) {
//                       // alert(JSON.stringify(ret)+'click')
//                         console.log(JSON.stringify(ret)+'click')
//                         if (ret.eventType == 'clickCancelFull') {
//                           quxiaoqunpingstate()
//                           _this.quanping = false
//                         } else if (ret.eventType == 'clickFullScreen') {
//                           _this.quanping = true
//                           quanpingstate()
// }
//                     }
//                 });
                //调节亮度和音量
                ijkplayer.addEventListener({
                    name: 'gesture'
                }, function(ret, err) {
                    if (ret) {
                        // console.log(JSON.stringify(ret)+'gesture')
                        var ijkplayer = api.require('ijkplayer');
                        //靠左上滑动
                        if (ret.gestureTap == 'gestureLeftUp') {
                            ijkplayer.getBrightness(function(ret, err) {
                                if (ret) {
                                    ret.brightness = ret.brightness + 1
                                    // console.log( ret.brightness+'leftup')
                                    ijkplayer.setBrightness({
                                        brightness: ret.brightness
                                    });
                                }
                            });
                            //靠左下滑动
                        } else if (ret.gestureTap == 'gestureLeftDown') {
                            ijkplayer.getBrightness(function(ret, err) {
                                if (ret) {
                                    ret.brightness = ret.brightness - 0.3
                                    // console.log( ret.brightness+'leftdown')
                                    ijkplayer.setBrightness({
                                        brightness: ret.brightness
                                    });
                                }
                            });
                            //靠右上滑动
                        } else if (ret.gestureTap == 'gestureRightUp') {
                            ijkplayer.getVolume(function(ret) {
                                if (ret) {
                                  // console.log(ret.volume)
                                    ret.volume = Number(ret.volume) + 0.1;
                                    // console.log( ret.volume+'rightup')
                                    if (ret.volum > 1) {
                                        ret.volum = 1
                                    }
                                    ijkplayer.setVolume({
                                        volume: ret.volume
                                    });
                                }
                            });
                            //靠右上滑动
                        } else if (ret.gestureTap == 'gestureRightDown') {
                            ijkplayer.getVolume(function(ret) {
                                if (ret) {
                                  // console.log(ret.volume)
                                    ret.volume = Number(ret.volume) - 0.1;
                                    // console.log( ret.volume+'rightdown')
                                    if (ret.volum < 0) {
                                        ret.volum = 0
                                    }
                                    ijkplayer.setVolume({
                                        volume: ret.volume
                                    });
                                }
                            });
                        } else if (ret.eventType == 'gestureTap') {
                          if (_this.eventType=='stateComplete') {
                          }else {
                            if (api.systemType=='ios') {
                                if (_this.isLock!==true) {
                                  _this.kongzhi();
                                  _this.suoding();
                                }
                            }else {
                              _this.kongzhi();
                              _this.suoding();
                            }
                          }
                        }  else if (ret.eventType == 'statePaused') {
                            // _this.suoding();
                        } else if (ret.eventType == 'gestureDoubleTap') {
                            if (_this.eventType=='stateComplete') {
                            }else {
                              _this.kongzhi2()
                            }
                        }else if (ret.eventType == 'gestureLeftUp') {
                          ijkplayer.getBrightness(function(ret, err) {
                            if (ret) {
                                var brightness = Number(ret.brightness) +1
                                // console.log(brightness)
                                ijkplayer.setBrightness({
                                    brightness: brightness
                                });
                            }
                          });
                        }else if (ret.eventType == 'gestureLeftDown') {
                          ijkplayer.getBrightness(function(ret, err) {
                              if (ret) {
                                  var brightness = Number(ret.brightness) - 0.3
                                  ijkplayer.setBrightness({
                                      brightness: brightness
                                  });
                              }
                          });
                        }else if (ret.eventType == 'gestureRightUp') {
                          ijkplayer.getVolume(function(ret) {
                              if (ret) {
                                  ret.volume = Number(ret.volume) + 0.03;
                                  // console.log(typeof ret.volume)
                                  if (ret.volum > 1.0) {
                                      ret.volum = 1
                                  }
                                  // console.log(typeof ret.volume)
                                  ijkplayer.setVolume({
                                      volume: ret.volume
                                  });
                              }
                          });
                        }else if (ret.eventType == 'gestureRightDown') {
                          ijkplayer.getVolume(function(ret) {
                              if (ret) {
                                  ret.volume = Number(ret.volume) - 0.03;
                                  // console.log(typeof ret.volume)
                                  if (ret.volum < 0) {
                                      ret.volum = 0
                                  }
                                  // console.log(ret.volume)
                                  ijkplayer.setVolume({
                                      volume: ret.volume
                                  });
                              }
                          });
                        }
                    }
                });
            },
            chongshi:function() {
              if (api.connectionType=="none") {
                  this.wangluo=true;
                  api.toast({
                      msg: '暂无网络',
                      duration: 2000,
                      location: 'bottom'
                  });
              }else {
                this.wangluo=false;
                var item ={id:api.pageParam.videoid}
                this.Openjieshao(item)
              }
            },
            Openjieshao: function(item) {
              var _this =this;
              api.closeFrame({
                  name: 'videocontrl'
              });
                api.closeFrame({
                    name: 'goumai'
                });
                api.closeFrame({
                    name: '4gplay'
                });
                api.closeFrame({
                    name: 'keguankan'
                });
                api.closeFrame({
                    name: 'beisu'
                });
                api.sendEvent({
                    name: 'guanbidaojishi'
                });
                api.closeFrame({
                    name: 'daojishi'
                });
                api.closeFrame({
                    name: '4gplay0'
                });
                clearInterval(this.settime)
                clearInterval(this.settime2)
                setTimeout(function() {
                  var ijkplayer = api.require('ijkplayer');
                  ijkplayer.removeEventListener({
                      name: 'state'
                  });
                  ijkplayer.close();
                  _this.dianjistast()
                  _this.playstate = false;
                  _this.videoid = item.id;
                  _this.getuserinfo();
                },50)
            },
            playmethod(playnum) {
                if(uid){
                  return playnum > 9999 ? (playnum / 10000).toFixed(1) + '万' : playnum+1
                }else {
                  return playnum > 9999 ? (playnum / 10000).toFixed(1) + '万' : playnum
                }
            },
            zanmethod(zannum) {
                return zannum > 9999 ? (zannum / 10000).toFixed(1) + '万' : zannum
            },
            getuserinfo() {
                var _this = this;
                if (uid) {
                    new rest().get('getUserInfo').datae({
                        uid: uid
                    }).success(function(res) {
                        if (res.flag == 1) {
                            if (res.msg[0].img) {
                                _this.avatar = res.msg[0].img;
                            } else {
                                _this.avatar = '../../image/VIP/gray_touxiang.png';
                            }
                            _this.nickname = res.msg[0].nickname;

                            // vip用户点击vip视频，不应该显示“购物车”按钮、“学分”按钮、”开通vip会员，观看更多优质影片”按钮
                            if (res.msg[0].level == 1) {
                                _this.isviphuiyuan = true;
                            } else {
                                _this.isviphuiyuan = false;
                            }
                            _this.level = res.msg[0].level
                            _this.getdetail(function(obj) {
                                    _this.videoinit(obj);
                                })
                                // alert(_this.isviphuiyuan)
                        } else {
                            if (res.msg[0] == '用户id已失效' || res.msg[0] == '用户id不存在') {
                                api.toast({
                                    msg: '账号异常',
                                    duration: 2000,
                                    location: 'middle'
                                });
                                $api.rmStorage('uid');
                                $api.rmStorage('session');
                                $api.rmStorage('mobile');
                                api.sendEvent({
                                    name: 'exitlogin'
                                });
                            }
                        }
                    }).error(function(err) {
                        console.log(JSON.stringify(err))
                    }).run()
                } else {
                    _this.nickname = $api.getStorage('youkenickname');
                    _this.getdetail(function(obj) {
                        _this.videoinit(obj);
                    })
                }
            },
            watch_video: function() {
                var _this = this;
                var date = new Date();
                var seperator1 = "-";
                var seperator2 = ":";
                var month = date.getMonth() + 1;
                var strDate = date.getDate();
                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }
                if (strDate >= 0 && strDate <= 9) {
                    strDate = "0" + strDate;
                }
                var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
                    " " + date.getHours() + seperator2 + date.getMinutes() +
                    seperator2 + date.getSeconds();


                _this.video_content = [{
                    "id": _this.videodetial.id,
                    "video_name": _this.videodetial.video_name,
                    "img": _this.videodetial.img,
                    "video_introduce_small": _this.videodetial.video_introduce_small,
                    "video_type": _this.videodetial.video_type,
                    'addtime':_this.videodetial.addtime,
                    'watch_time': _this.watchtimes,
                    'isweixuan': true,
                    'watch_baifen':0
                }]
                // alert(JSON.stringify(_this.video_content))
                var histortlist = $api.getStorage('histortlist');
                if (typeof histortlist == 'object' && histortlist.length != 0) {
                    console.log(_this.video_content[0])
                    var flag;
                    for (var i = 0; i < histortlist.length; i++) {
                        if (histortlist[i].id != _this.video_content[0].id) {
                            flag = true;
                        } else {
                            flag = false;
                            histortlist.splice(i, 1);
                            break;
                        }
                    }
                    // if (flag) {
                        histortlist.push(_this.video_content[0])
                        $api.setStorage('histortlist', histortlist);
                    // }
                    api.sendEvent({
                        name: 'watchvideo',
                    });

                } else {
                    $api.setStorage('histortlist', _this.video_content);
                    api.sendEvent({
                        name: 'watchvideo',
                    });
                }

                //  alert(JSON.stringify($api.getStorage('histortlist')))


            },
            getdetail(back) {
                var _this = this;
                if (uid) {
                    var data1 = {
                        video_id: _this.videoid,
                        uid: uid
                    }
                } else {
                    var data1 = {
                        video_id: _this.videoid,
                        uid: ''
                    }
                }
                // alert(JSON.stringify(data1))
                new rest().get('getDetail').datae(data1).success(function(res) {
                    // console.log(JSON.stringify(res))
                    // console.log('*****************************************************************************')
                    if (res.flag == 1) {
                        _this.videodetial = res.msg;
                        // console.log(JSON.stringify(res.msg))
                        if (uid) {
                        Vue.set(_this.videodetial, 'isZan', res.msg.isZan)
                      }else {
                        Vue.set(_this.videodetial, 'isZan', 0)
                      }
                        if (!uid) {
                            _this.watch_video();
                        }
                        api.download({
                            url: res.msg.img,
                            savePath: '',
                            report: true,
                            cache: true,
                            allowResume: true
                        }, function(ret, err) {
                            if (ret.state == 1) {
                                //下载成功
                                _this.videobg = ret.savePath
                                // alert(JSON.stringify(ret))
                                if (typeof back == 'function') {
                                    back(res.msg)
                                }
                            } else {

                            }
                        });

                        // 首页监听，修改观看次数
                        api.sendEvent({
                            name: 'yibofang',
                        });
                        // 获取作者相关视频
                        _this.getauthorvideo(res.msg.author_id);
                    }


                }).error(function(err) {
                    console.log(JSON.stringify(err))
                }).run()

            },
            // yiduihuan(){
            //   api.toast({
            //       msg: '已兑换过',
            //       duration: 2000,
            //       location: 'middle'
            //   });
            // },
            watchtime(riqi) {
                return Mou.watchtime(riqi);
            },
            collect: function() {
                var _this = this;
                if (uid) {
                    new rest().post('addFavorite').datae({
                        _uid: uid,
                        session: session,
                        video_id: _this.videoid,
                    }).success(function(res) {
                        if (res.flag == 1) {
                            Vue.set(_this.videodetial, 'isFavorite', '1')
                            $('.collectsuccess').css('display', 'block');
                            setTimeout(function() {
                                $('.collectsuccess').css('display', 'none');
                            }, 500);
                            // $('.big-box').css('display', 'block');
                            // setTimeout(function() {
                            //     $('.big-box').css('display', 'none');
                            // }, 2000);
                            api.sendEvent({
                                name: 'collectcaozuo',
                            });
                            // _this.getdetail();
                        } else {
                            api.toast({
                                msg: res.msg,
                                duration: 500,
                                location: 'bottom'
                            });
                        }
                    }).error(function(err) {
                        api.toast({
                            msg: err.msg,
                            duration: 2000,
                            location: 'bottom'
                        });
                    }).run()
                }else{
                  openloginwin()
                }
            },
            discollect: function() {
                var _this = this;
                // 取消收藏
                if (uid) {
                    new rest().post('unFavorite').datae({
                        _uid: uid,
                        session: session,
                        video_id: _this.videoid,
                    }).success(function(res) {

                        if (res.flag == 1) {
                          api.sendEvent({
                              name: 'collectcaozuo',
                          });

                            Vue.set(_this.videodetial, 'isFavorite', '0')
                            api.toast({
                                msg: '取消收藏成功',
                                duration:500,
                                location: 'bottom'
                            });
                            // _this.getdetail();
                        } else {
                            api.toast({
                                msg: res.msg,
                                duration: 200,
                                location: 'bottom'
                            });
                        }
                    }).error(function(err) {
                        api.toast({
                            msg: err.msg,
                            duration: 2000,
                            location: 'bottom'
                        });
                    }).run()
                } else {
                    Vue.set(_this.videodetial, 'isFavorite', '0')
                    $api.setStorage('isFavorite', '0');
                    openloginwin()

                }

            },
            watchtime(riqi) {
                return Mou.watchtime(riqi);
            },
            OpenWatchAllVieo(authorname, authorid, videoid) {
                // 打开作者所有视频列表
                var videostate=0;
                  if (vm.vidoeadstate=='statePlaying') {
                    videostate=1;
                    api.sendEvent({
                        name: 'zantingvideoad'
                    });
                    vm.zanting()
                  }else {
                    vm.zanting()
                  }
                api.openWin({
                    name: 'auther',
                    url: 'author_win.html',
                    pageParam: {
                        authorname: authorname,
                        authorid: authorid,
                        videoid: videoid,
                        value:videostate
                    }
                });
            },

            duihuan(videoxuefen, riqi,isyongjiu) {
                var _this = this;
                var videostate=0;
                  if (vm.vidoeadstate=='statePlaying') {
                    videostate=1;
                    api.sendEvent({
                        name: 'zantingvideoad'
                    });
                    vm.zanting()
                  }else {
                    vm.zanting()
                  }
                api.openFrame({
                    name: 'xuefenduihuan',
                    url: './xuefenduihuan.html',
                    rect: {
                        x: 0,
                        y: 0,
                        w: 'auto',
                        h: 'auto'
                    },
                    pageParam: {
                        videoxuefen: videoxuefen,
                        riqi: riqi,
                        isyongjiu:isyongjiu,
                        videoid: _this.videoid,
                        value:videostate
                    },
                    bounces: false,
                    bgColor: 'rgba(0,0,0,0)',
                    vScrollBarEnabled: true,
                    hScrollBarEnabled: true,

                });
            },
            goumai(videocash, videoid, riqi,isyongjiu) {
              var _this = this;
              var videostate=0;
                if (vm.vidoeadstate=='statePlaying') {
                  videostate=1;
                  api.sendEvent({
                      name: 'zantingvideoad'
                  });
                  vm.zanting()
                }else {
                  vm.zanting()
                }
                api.openFrame({
                    name: 'unvip_buyvideo',
                    url: './unvip_buyvideo.html',
                    rect: {
                        x: 0,
                        y: 0,
                        w: 'auto',
                        h: 'auto'
                    },
                    pageParam: {
                        videocash: videocash,
                        videoid: videoid,
                        isyongjiu:isyongjiu,
                        riqi: riqi,
                        value:videostate
                    },
                    bounces: false,
                    bgColor: 'rgba(0,0,0,0)',
                    vScrollBarEnabled: true,
                    hScrollBarEnabled: true
                });
            },
            goumaidaka(videocash, videovipcash, videoid, riqi,isyongjiu) {
                var _this = this;
                var videostate=0;
                  if (vm.vidoeadstate=='statePlaying') {
                    videostate=1;
                    api.sendEvent({
                        name: 'zantingvideoad'
                    });
                    vm.zanting()
                  }else {
                    vm.zanting()
                  }
                if (_this.isviphuiyuan) {
                    api.openFrame({
                        name: 'undakavip_buyvideo',
                        url: './undakavip_buyvideo.html',
                        rect: {
                            x: 0,
                            y: 0,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam: {
                            videocash: videocash,
                            videovipcash: videovipcash,
                            videoid: videoid,
                            riqi: riqi,
                            isyongjiu:isyongjiu,
                            value:videostate
                        },
                        bounces: false,
                        bgColor: 'rgba(0,0,0,0)',
                        vScrollBarEnabled: true,
                        hScrollBarEnabled: true
                    });
                } else {
                    api.openFrame({
                        name: 'undakaunvip_buyvideo',
                        url: './undakaunvip_buyvideo.html',
                        rect: {
                            x: 0,
                            y: 0,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam: {
                            videocash: videocash,
                            videovipcash: videovipcash,
                            videoid: videoid,
                            riqi: riqi,
                            isyongjiu:isyongjiu,
                            value:videostate
                        },
                        bounces: false,
                        bgColor: 'rgba(0,0,0,0)',
                        vScrollBarEnabled: true,
                        hScrollBarEnabled: true
                    });
                }
                setTimeout(function() {
                api.bringFrameToFront({
                    from: 'undakavip_buyvideo'
                });
                api.bringFrameToFront({
                    from: 'undakaunvip_buyvideo'
                })
              },100)

            },
            getauthorvideo(authorid) {
                var _this = this;
                // 作者相关视频
                new rest().post('getAuthorVideo').datae({
                    author: authorid,
                    video_id: _this.videoid,
                }).success(function(res) {
                    if (res.flag == 1) {
                        if (res.msg.length > 0) {
                            _this.authorvideolist = res.msg;
                            _this.isauthorvideolistflag = true;
                        } else {
                            _this.isauthorvideolistflag = false;
                        }
                    } else {
                        api.toast({
                            msg: res.msg,
                            duration: 2000,
                            location: 'middle'
                        });
                    }
                }).error(function(err) {
                    api.toast({
                        msg: err.msg,
                        duration: 2000,
                        location: 'middle'
                    });
                }).run()
            },
            isFullScreen: function(back) {
                var _this = this;
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.isFullScreen(function(ret) {
                    if (ret.status) {
                        _this.quanping = true;
                    } else {
                        _this.quanping = false;
                    }
                    if (typeof back == 'function') {
                        back()
                    }
                });
            },
            beisuplay(ret) {
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.setSpeed({
                    speed: ret
                }, function(ret2) {
                    if (ret2) {
                        // console.log(JSON.stringify(ret2));
                        api.toast({
                            msg: ret + '倍速播放',
                            duration: 2000,
                            location: 'bottom'
                        });

                    }
                });
            },
            videoinit: function(obj) {
                var _this = this;

                var playtype = false;
                //返回按钮
                    //已购买
                    // alert(JSON.stringify(_this.videodetial))
                if (_this.videodetial.is_valite == 1) {
                    openvideocontrl(0)
                    playtype = true
                        //未购买
                        _this.wangluo2()
                        if (_this.ifliuliang) {
                            playtype = false
                          // var ad = false;
                          // if (obj.video_ad) {
                          //     ad = true
                          // }
                            playtype = false
                            api.openFrame({
                                name: '4gplay',
                                url: './../video/4gplay.html',
                                rect: {
                                    x: api.frameWidth / 2 - 80,
                                    y: 80 + api.safeArea.top,
                                    w: 160,
                                    h: 40
                                },
                                pageParam: {
                                    bgColor:_this.videobg,
                                    size: _this.videodetial.size
                                }
                            });
                            _this.bofangvideo(playtype)
                        }else {
                            _this.bofangvideo(playtype)
                        }

                } else {
                    //如果视频是vip视频
                    if (_this.videodetial.video_type == 2) {
                        if (_this.level == 1) {
                          playtype = true
                          openvideocontrl(0)
                        } else {
                          playtype = true
                          openkeguankan(_this.videodetial.video_free_look, 2, 0,_this.videodetial)
                          openvideocontrl(_this.videodetial.video_free_look, _this.videodetial)

                        }
                        //如果视频是大咖视频
                    } else if (_this.videodetial.video_type == 3) {
                      // alert(JSON.stringify(_this.videodetial))
                        if (_this.level == 1) {
                            playtype = true
                            openvideocontrl(_this.videodetial.video_vip_look, _this.videodetial)
                            openkeguankan(_this.videodetial.video_vip_look, 3, 1,_this.videodetial)
                        } else {
                            playtype = true
                            openvideocontrl(_this.videodetial.video_free_look, _this.videodetial)
                            openkeguankan(_this.videodetial.video_free_look, 3, 0,_this.videodetial)
                        }

                    } else {
                        playtype = true
                        openvideocontrl(0)
                    }

                if (obj.video_ad ) {
                    playtype = false
                    _this.wangluo2()
                    if (_this.ifliuliang) {
                        playtype = false
                        api.openFrame({
                            name: '4gplay0',
                            url: './../video/4gplay0.html',
                            rect: {
                              x: 0,
                              y: api.safeArea.top,
                              w: api.frameWidth,
                              h: 210
                            },
                            pageParam: {
                                bgColor:_this.videobg,
                                size: _this.videodetial.size,
                                videad :1
                            }
                        });
                        // _this.playvidoead(obj)
                    }else {
                        _this.playvidoead(obj)
                    }
                } else {
                  playtype =true
                    _this.wangluo2()
                    if (_this.ifliuliang) {
                        playtype = false
                        api.openFrame({
                            name: '4gplay',
                            url: './../video/4gplay.html',
                            rect: {
                                x: api.frameWidth / 2 - 80,
                                y: 80 + api.safeArea.top,
                                w: 160,
                                h: 40
                            },
                            pageParam: {
                                size: _this.videodetial.size
                            }
                        });
                        _this.bofangvideo(playtype)
                    }else {
                      _this.bofangvideo(playtype)
                    }
                }
              }

              openfanhui()
            },
            playvidoead:function(obj) {
              var _this =this;
              var ijkplayer = api.require('ijkplayer');
              ijkplayer.removeEventListener({
                  name: 'state'
              });
              api.openFrame({
                  name: 'videoad',
                  url: './../video/videoad.html',
                  rect: {
                      x: 0,
                      y: api.safeArea.top,
                      w: api.frameWidth,
                      h: 210
                  },
                  pageParam: {
                      videourl: obj,
                      videoadurl:obj.video_ad_url,
                      videobg:_this.videobg,
                      safetop:api.safeArea.top
                  },
                  bounces: false,
                  bgColor: '#fff',
                  vScrollBarEnabled: true,
                  hScrollBarEnabled: true,
              });
              api.setFrameAttr({
                  name: 'beisu',
                  hidden: true
              });
              api.setFrameAttr({
                  name: 'videocontrl',
                  hidden: true
              });
              this.kongzhiflage = false
            },
            bofangvideo:function(playtype) {
              var _this =this;
              // alert(JSON.stringify(_this.videodetial))
              var ijkplayer = api.require('ijkplayer');
              var systemTypeh = 210;
              // if (api.systemType == 'ios') {
              //     systemTypeh = 210;
              // }
              ijkplayer.open({
                  rect: {
                      x: 0,
                      y: api.safeArea.top,
                      w: api.frameWidth,
                      h: systemTypeh
                  },
                  styles: {
                    repeat:{
                       repeatwidth: 100,                 //（可选项）数字类型；重新播放按钮的宽；默认：40
                       repeatheight: 100,                 //（可选项）数字类型；重新播放按钮的高；默认：60
                       repeatImg:'widget://image/bofang.png',  //（可选项）字符串类型；重新播放按钮的背景图片，要求本地路径（widget://、fs://）；默认：重新播放小图标

                    },lock: {
                        hide: true
                    },
                      head: {
                          hide: true
                      },
                      foot: {
                          hide: true
                      }
                  },
                  // path: 'http://7o50kb.com2.z0.glb.qiniucdn.com/c1.1.mp4',
                  // path: 'http://pi6yroy0p.bkt.clouddn.com/1%20-%20%E5%89%AF%E6%9C%AC.mp4',
                  path: _this.videodetial.video,
                  autoPlay: playtype,
                  movieScaling: 'scaleAspectFit',
                  coverImg:_this.videobg,
                  isFullBtn: false,
                  isBackBtn: false,
                  isShowTimeLable: false,
                  isSmallOpenGesture: false,
                  isOpenGesture: false,
                  isAutorotate:false,
                  fixedOn: api.frameName,
                  fixed: true
              });
              // if (_this.videodetial.last_watch) {
                // var gotime = parseInt(_this.videodetial.last_watch/1000);
                // setTimeout(function() {
                  // ijkplayer.seekTo({
                      // seconds: gotime
                  // });
                // },1000)
              // }
            },
            kongzhi: function() {
                if (this.kongzhiflage) {
                    api.setFrameAttr({
                        name: 'beisu',
                        hidden: true
                    });
                    api.setFrameAttr({
                        name: 'videocontrl',
                        hidden: true
                    });
                    api.setFrameAttr({
                        name: 'suoding',
                        hidden: true
                    });
                    this.kongzhiflage = false
                } else {
                    if (this.quanping) {
                        api.openFrame({
                            name: 'beisu',
                            url: './../video/beisu1.html',
                            rect: {
                                x: (api.frameWidth-520)/2,
                                // y: 10,
                                y: 10 + api.safeArea.top,
                                w: 520,
                                h: 40
                            }
                        });
                        api.setFrameAttr({
                            name: 'beisu',
                            hidden: false
                        });
                        // if (api.systemType!='ios') {
                          api.openFrame({
                              name: 'suoding',
                              url: './../video/suoding.html',
                              rect: {
                                  x: 35,
                                  y: api.frameHeight / 2 - 20,
                                  w: 40,
                                  h: 30
                              }
                          });
                        // }
                        api.setFrameAttr({
                            name: 'suoding',
                            hidden: false
                        });
                    }
                    api.setFrameAttr({
                        name: 'videocontrl',
                        hidden: false
                    });
                    this.kongzhiflage = true
                }
            },
            kongzhi2: function() {
                api.setFrameAttr({
                    name: 'videocontrl',
                    hidden: false
                });
            },
            suoding() {
                // if (this.quanping) {
                //   api.openFrame({
                //       name: 'suoding',
                //       url: './../video/suoding.html',
                //       rect: {
                //           x: 10,
                //           y: api.frameHeight/2-20,
                //           w: 40,
                //           h: 30
                //       }
                //   });
                // }
                // else {
                //   api.openFrame({
                //       name: 'suoding',
                //       url: './../video/suoding.html',
                //       rect: {
                //           x: 10,
                //           y: 110,
                //           w: 40,
                //           h: 30
                //       }
                //   });
                // }

            },
            upwatch:function() {
              // var _this =this;
              // var alltimem,currenttime;
              // var ijkplayer = api.require('ijkplayer');
              // ijkplayer.getDuration(function(ret) {
              //     if (ret) {
              //         alltimem = ret.duration;
              //         ijkplayer.getCurrentPosition(function(ret) {
              //             if (ret) {
              //                 currenttime = ret.currentPosition
              //                 new rest().post('updateWatchTime').datae({
              //                     uid: uid,
              //                     watch_time: currenttime/alltimem,
              //                     video_id: _this.videoid,
              //                 }).success(function(res) {
              //                       console.log(JSON.stringify(res)+'观看到了'+currenttime);
              //                 }).error(function(err) {
              //                     api.toast({
              //                         msg: err.msg,
              //                         duration: 2000,
              //                         location: 'middle'
              //                     });
              //                 }).run()
              //             }
              //         });
              //     }
              // });
            },
            updateVideoTime:function(ob){
              var _this =this;
              new rest().post('updateVideoTime').datae({
                  time: ob,
                  video_id: _this.videoid,
              }).success(function(res) {
                    // console.log(JSON.stringify(res)+'总时长');
              }).error(function(err) {
                  api.toast({
                      msg: err.msg,
                      duration: 2000,
                      location: 'middle'
                  });
              }).run()
            },
            bofangtime: function() {
              var _this =this;
              var alltimem,currenttime;
                var ijkplayer = api.require('ijkplayer');
                setTimeout(function() {
                    ijkplayer.getDuration(function(ret) {
                      // alert(ret.duration)
                        if (ret) {
                            api.sendEvent({
                                name: 'alltime',
                                extra: {
                                    value: ret.duration,
                                }
                            });
                            alltimem = ret.duration;
                            _this.alltime = alltimem;
                            _this.updateVideoTime(ret.duration)
                        }
                    });
                }, 1000)

                this.settime = setInterval(function() {
                    ijkplayer.getCurrentPosition(function(ret) {
                        if (ret) {
                            api.sendEvent({
                                name: 'positiotime',
                                extra: {
                                    value: ret.currentPosition,
                                }
                            });
                            currenttime = ret.currentPosition
                            _this.watchtimes = currenttime/alltimem
                        }
                    });
                }, 1000)

                this.settime2 = setInterval(function() {
                  if (uid) {
                  // http://47.94.16.190/study/public/api/Video/updateWatchTime/uid/1/video_id/14/watch_time/1
                  new rest().post('updateWatchTime').datae({
                      uid: uid,
                      watch_time: currenttime,
                      video_id: _this.videoid,
                  }).success(function(res) {
                      api.sendEvent({
                          name: 'watchhistory',
                          extra: {
                              watch_time:currenttime,
                              video_id:_this.videoid
                          }
                      });

                        // console.log(JSON.stringify(res)+'观看到'+currenttime);
                  }).error(function(err) {
                      api.toast({
                          msg: err.msg,
                          duration: 2000,
                          location: 'middle'
                      });
                  }).run()
                }else {
                  // _this.watch_video();
                }
              },4000)



            },
            bofang: function() {
                // if (this.playstate) {
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.play();
                // } else {
                    // this.replay()
                // }
            },
            replay: function() {
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.replay();
            },
            zanting: function() {
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.pause();
                clearInterval(this.settime)
                clearInterval(this.settime2)
            },
            full: function() {
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.fullScreen();
            },
            unfull: function() {
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.cancelFullScreen();
            },
            seekTo: function(ret) {
              // alert(ret)
                var ijkplayer = api.require('ijkplayer');
                ijkplayer.seekTo({
                    seconds: ret
                });
            },
            transform: function() {
                var _this = this;
                _this.dianjiflag = false;
                $(".dianji").removeClass('hide');
                $(".dianzan").addClass('hide');
                $(".share").addClass('hide');
                $(".lists").addClass('hide');
            },
            transforms: function() {
                var _this = this;
                _this.dianjiflag = true;
                $(".dianji").addClass('hide');
                $(".dianzan").removeClass('hide');
                $(".share").removeClass('hide');
                $(".lists").removeClass('hide');
            },
            change: function() {
                var _this = this;
                _this.flage = false;
            },
            changes: function() {
                var _this = this;
                _this.flage = true;
            },
            cancelzan: function() {
                var _this = this;
                if (_this.xiuxi) {
                  return false;
                }else {
                if (uid) {
                    _this.xiuxi = true;
                    new rest().post('unzanVideo').datae({
                        _uid: uid,
                        session: session,
                        video_id: _this.videoid,
                    }).success(function(res) {
                        if (res.flag == 1) {
                            Vue.set(_this.videodetial, 'isZan', '0')
                            // console.log(zancount)
                            _this.weidianji=false;
                            _this.weidianji1=true;
                            setTimeout(function() {
                              var zancount = parseInt(_this.videodetial.zan_count) - 1
                              if (zancount <= 0) {
                                  zancount = 0
                              }
                              Vue.set(_this.videodetial, 'zan_count', zancount)
                              _this.xiuxi = false;
                            },500)
                        } else {
                            api.toast({
                                msg: res.msg,
                                duration: 1000,
                                location: 'middle'
                            });
                        }
                    }).error(function(err) {
                        api.toast({
                            msg: err.msg,
                            duration: 1000,
                            location: 'middle'
                        });
                    }).run()
                }else{
                  openloginwin()
                }
              }

            },
            zan: function() {
                var _this = this;
                if (_this.xiuxi) {
                  return false;
                }else {
                if (uid) {
                  _this.xiuxi = true;
                    new rest().post('zanVideo').datae({
                        _uid: uid,
                        session: session,
                        video_id: _this.videoid,
                    }).success(function(res) {
                        if (res.flag == 1) {
                            Vue.set(_this.videodetial, 'isZan', '1');
                            _this.weidianji1=false;
                            _this.weidianji=true;
                            setTimeout(function() {
                              var zancount = parseInt(_this.videodetial.zan_count) + 1
                              Vue.set(_this.videodetial, 'zan_count', zancount);
                              _this.xiuxi = false;
                            },500)
                        } else {
                            api.toast({
                                msg: res.msg,
                                duration: 1000,
                                location: 'middle'
                            });
                        }
                    }).error(function(err) {
                        api.toast({
                            msg: err.msg,
                            duration: 1000,
                            location: 'middle'
                        });
                    }).run()
                }else{
                  openloginwin()
                }
              }
            },
            share(isrecommend) {
                // if (isrecommend == 1) {
                    api.openFrame({
                        name: 'share',
                        url: 'share.html',
                        rect: {
                            x: 0,
                            y: 0,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam: {
                            sharetitle: vm.videodetial.video_name,
                            description: vm.videodetial.video_introduce,
                            videoid: vm.videoid
                        },
                        bounces: false,
                        bgColor: 'rgba(0,0,0,0.7)',
                        vScrollBarEnabled: true,
                        hScrollBarEnabled: true
                    });

                    api.addEventListener({
                        name: 'zhuanfa'
                    }, function(ret, err) {
                        if (uid) {
                            var data = {
                                _uid: uid,
                                session: session,
                                type: 2
                            }
                            new rest().get('share').datae(data).success(function(res) {
                            // alert(JSON.stringify(res))
                                if (res.flag == 1) {
                                  api.toast({
                                      msg: '分享成功',
                                      duration: 2000,
                                      location: 'middle'
                                  });
                                    // if(res.msg=="分享成功"){
                                    //   api.toast({
                                    //       msg: res.msg,
                                    //       duration: 2000,
                                    //       location: 'middle'
                                    //   });
                                    // }else{
                                    //   $('.sharesuccess').css('display', 'block');
                                    //   setTimeout(function() {
                                    //       $('.sharesuccess').css('display', 'none');
                                    //   }, 1500);
                                    // }

                                    api.sendEvent({
                                        name: 'sharevideosuccess',
                                    });
                                } else {
                                    api.toast({
                                        msg: res.msg,
                                        duration: 2000,
                                        location: 'middle'
                                    });
                                }


                                // console.log(JSON.stringify(res))
                            }).error(function(err) {
                                console.log(JSON.stringify(err))
                            }).run()
                        } else {
                          api.toast({
                              msg: '分享成功',
                              duration: 2000,
                              location: 'middle'
                          });
                          // $('.sharesuccess').css('display', 'block');
                          //    setTimeout(function() {
                          //        $('.sharesuccess').css('display', 'none');
                          //    }, 1500);

                        }

                    });
                // } else {
                //     api.toast({
                //         msg: '该视频不是推荐视频',
                //         duration: 2000,
                //         location: 'middle'
                //     });
                //
                // }

            }
        }
    })

    function openvideocontrl(ret, videodetail) {
        api.openFrame({
            name: 'videocontrl',
            url: './../video/video.html',
            rect: {
                x: 0,
                y: 145 + api.safeArea.top,
                w: api.frameWidth,
                h: 64
            },
            reload:true,
            pageParam: {
                freetime: ret,
                videodetail: videodetail,
                safeArea:api.safeArea.top
            },
        });
    }

    function openkeguankan(ret, videotype, usertype,videodetail) {
       if(ret){
        api.openFrame({
            name: 'keguankan',
            url: './../video/keguankan.html',
            rect: {
                x: api.frameWidth - 230,
                y: 10 + api.safeArea.top,
                w: 250,
                h: 40
            },
            pageParam: {
                freetime: ret,
                videotype: videotype,
                usertype: usertype,
                videodetail:videodetail
            },
            reload:true,
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });
      }
    }

    function quxiaoqunpingstate() {
        api.sendEvent({
            name: 'statefull',
            extra: {
                value: 0,
            }
        });
        setTimeout(function() {
            api.setFrameAttr({
                name: 'videocontrl',
                rect: {
                    x: 0,
                    y: 145 + api.safeArea.top,
                    w: api.frameWidth,
                    h: 64
                },
                bounces: false,
                bgColor: 'rgba(255,255,255,0)',
                vScrollBarEnabled: false,
                hScrollBarEnabled: false
            });
            api.setFrameAttr({
                name: 'goumai',
                rect: {
                    x: 0,
                    y: api.safeArea.top,
                    w: api.frameWidth,
                    h: 210
                }
            });
            api.setFrameAttr({
                name: 'beisu',
                hidden: true
            });
            api.setFrameAttr({
                name: 'keguankan',
                rect: {
                    x: api.frameWidth - 230,
                    y: 10 + api.safeArea.top,
                    w: 250,
                    h: 40
                },
            });
            api.setFrameAttr({
                name: 'suoding',
                hidden: true
            });
            // api.setFrameAttr({
            //     name: 'suoding',
            //     rect: {
            //         x: 0,
            //         y: api.safeArea.top+90,
            //         w: 40,
            //         h: 30
            //     }
            // });
            if (vm.liuliangflag) {
                api.openFrame({
                    name: '4gplay',
                    url: './../video/4gplay.html',
                    rect: {
                        x: api.frameWidth / 2 - 80,
                        y: 80 + api.safeArea.top,
                        w: 160,
                        h: 40
                    }
                });
            }
        }, 300)
    }

    function quanpingstate() {
        api.sendEvent({
            name: 'statefull',
            extra: {
                value: 1,
            }
        });
        var frameWidth,frameHeight;
        if (api.systemType=='ios') {
           frameWidth=api.frameHeight;
           frameHeight=api.frameWidth
        }else {
          frameWidth=api.frameWidth
          frameHeight=api.frameHeight
        }
        api.setFrameAttr({
            name: 'goumai',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto',
            }
        });
        api.setFrameAttr({
            name: 'videocontrl',
            rect: {
                x: 0,
                y: frameWidth-70-api.safeArea.bottom,
                w: 'auto',
                h: 64
            },
            bounces: false,
            bgColor: 'rgba(255,255,255,0)',
            vScrollBarEnabled: false,
            hScrollBarEnabled: false
        });
        api.setFrameAttr({
            name: 'beisu',
            rect: {
                x: 0,
                y: 5 + api.safeArea.top,
                w: 'auto',
                h: 40
            }
        });
        api.setFrameAttr({
            name: 'keguankan',
            rect: {
                x: frameHeight - 250,
                y: 10 + api.safeArea.top,
                w: 250,
                h: 40
            },
        });
        api.setFrameAttr({
            name: 'suoding',
            rect: {
                x: 35,
                y: frameWidth / 2 - 20,
                w: 40,
                h: 30
            }
        });
        if (vm.liuliangflag) {
            api.openFrame({
                name: '4gplay',
                url: './../video/4gplay.html',
                rect: {
                    x: frameHeight / 2 - 80,
                    y: 80 + api.safeArea.top,
                    w: 160,
                    h: 40
                }
            });
        }
    }

    function detail() {
        api.openWin({
            name: 'video_detail',
            url: './video_detail.html',

        });

    }

    function play() {
        api.openWin({
            name: 'startvideo',
            url: './startvideo.html',

        });
        api.closeWin();
    }



    function openfanhui() {
      // alert(api.safeArea.top)
      // var footerh=$api.fixTabBar($api.byId('footer'))
        api.openFrame({
            name: 'fanhui',
            url: './../video/fanhui.html',
            rect: {
                x: 20,
                y: 20+api.safeArea.top,
                w: 40,
                h: 40

            },
            bgColor: 'rgba(0,0,0,0)',
        });
    }

    function openVIP() {
      var videostate=0;
        if (vm.vidoeadstate=='statePlaying') {
          videostate=1;
          api.sendEvent({
              name: 'zantingvideoad'
          });
          vm.zanting()
        }else {
          vm.zanting()
        }
        api.openWin({
            name: 'unbuy_vip_win',
            url: './unbuy_vip_win.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true,
            pageParam: {
              value:videostate
            },
        });
        setTimeout(function() {
        api.bringFrameToFront({
            from: 'unbuy_vip_win'
        });
      },100)
    }
    function openloginwin() {
      var videostate=0;
        if (vm.vidoeadstate=='statePlaying') {
          videostate=1;
          api.sendEvent({
              name: 'zantingvideoad'
          });
          vm.zanting()
        }else {
          vm.zanting()
        }
        if(vm.eventType==1){
          api.toast({
              msg: '视频缓冲中',
              duration: 2000,
              location: 'bottom'
          });

        }else {
          api.openFrame({
              name: 'login_introduction',
              url: '../myself/login_introduction.html',
              rect: {
                  x: 0,
                  y: 0,
                  w: 'auto',
                  h: 'auto'
              },
              bounces: false,
              bgColor: 'rgba(0,0,0,0.7)',
              pageParam: {
                value:videostate
              },
              vScrollBarEnabled: true,
              hScrollBarEnabled: true
          });
        }

    }
</script>

</html>
